<template>
  <div class="admin-page">
    <!-- 未登录状态 -->
    <div v-if="!isAdmin" class="login-prompt">
      <div class="prompt-container">
        <div class="prompt-icon">
          <el-icon><Lock /></el-icon>
        </div>
        <h2 class="prompt-title">需要管理员权限</h2>
        <p class="prompt-desc">您需要登录管理员账号才能访问此页面</p>
        <div class="prompt-actions">
          <el-button 
            type="primary" 
            @click="router.push('/admin-login')"
            class="login-button"
          >
            <el-icon class="mr-2"><Key /></el-icon>
            前往登录
          </el-button>
          <el-button 
            @click="router.push('/preview')"
          >
            <el-icon class="mr-2"><Back /></el-icon>
            返回首页
          </el-button>
        </div>
      </div>
    </div>
    
    <!-- 已登录状态 -->
    <div v-else>
      <router-view />
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useRouter } from 'vue-router';
import { useMainStore } from '../store';
import { Lock, Key, Back } from '@element-plus/icons-vue';

const router = useRouter();
const store = useMainStore();

// 判断是否为管理员
const isAdmin = computed(() => store.isAdmin);
</script>

<style scoped>
.admin-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(249, 115, 22, 0.05) 100%);
}

.login-prompt {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.prompt-container {
  max-width: 500px;
  background-color: white;
  border-radius: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.prompt-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.prompt-icon .el-icon {
  font-size: 40px;
  color: white;
}

.prompt-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #3b82f6, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.prompt-desc {
  color: #6b7280;
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.prompt-actions {
  display: flex;
  gap: 1rem;
}

.login-button {
  background: linear-gradient(135deg, #3b82f6, #f97316);
  border: none;
  transition: all 0.3s ease;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

@media (max-width: 640px) {
  .prompt-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .prompt-container {
    padding: 2rem 1.5rem;
  }
}
</style> 